package UnitTest.DataStructureTest.arrayAndListTest.listTest.listReverseTest;

import DataStructure.arrayAndList.list.Nodelj;
import DataStructure.arrayAndList.list.listReverse.ListReversePartN;
import org.junit.Test;

/**
 * @author liujun
 * @version 1.0
 * @date 2021/12/7
 * @author—Email ljfirst@mail.ustc.edu.cn
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 每N个数反转一次
 */
public class ListReversePartNTest extends ListReverseDate {

    Nodelj node = new Nodelj();

    @Test
    public void test() {
        test(new ListReversePartN());
    }

    public void test(ListReversePartN instance) {
        Nodelj answer = instance.reverse(node.Array2Nodelj(array01), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_01));
        answer = instance.reverse(node.Array2Nodelj(array02), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_02));
        answer = instance.reverse(node.Array2Nodelj(array03), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_03));
        answer = instance.reverse(node.Array2Nodelj(array04), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_04));
        answer = instance.reverse(node.Array2Nodelj(array05), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_05));
        answer = instance.reverse(node.Array2Nodelj(array06), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_06));
        answer = instance.reverse(node.Array2Nodelj(array07), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_07));
        answer = instance.reverse(node.Array2Nodelj(array08), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_08));
        answer = instance.reverse(node.Array2Nodelj(array09), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_09));
        answer = instance.reverse(node.Array2Nodelj(array10), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_10));
        answer = instance.reverse(node.Array2Nodelj(array11), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_11));
        answer = instance.reverse(node.Array2Nodelj(array12), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_12));
        answer = instance.reverse(node.Array2Nodelj(array13), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_13));
        answer = instance.reverse(node.Array2Nodelj(array14), 2);
        assert node.equals(answer, node.Array2Nodelj(array_SwapPairs_14));
    }
}
